package com.uzai.console.dto.tb.tborder;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.taobao.api.internal.toplink.embedded.websocket.util.StringUtil;
import com.uzai.console.common.utils.DateUtil;
import com.uzai.console.common.utils.Tools;
import com.uzai.console.dto.QueryParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * @Auther: liuqi
 * @Date: 2021/8/10 14:58
 * @Description:
 */
@ApiModel("淘宝订单查询参数")
public class TbOrderQuery extends QueryParam {

    @ApiModelProperty("订单编号")
    private String orderNo;
    @ApiModelProperty("父订单编号")
    private String parentOrderNo;
    @ApiModelProperty("用户ID")
    private Long userId;
    @ApiModelProperty("用户昵称")
    private String nickName;
    @ApiModelProperty("商品名称")
    private String title;
    @ApiModelProperty("商品ID")
    private String itemId;
    @ApiModelProperty("机器人ID")
    private Long deviceUniqueId;
    @ApiModelProperty("机器人ID列表")
    private List<Long> deviceUniqueIdList;
    @ApiModelProperty("商品类目")
    private Integer cid;
    @ApiModelProperty("订单状态(0订单付款 1订单结算 2订单失效 3维权中 4维权成功)")
    private Integer status;
    @ApiModelProperty(value = "订单状态集合(0订单付款 1订单结算 2订单失效 3维权中 4维权成功)", hidden = true)
    private List<Integer> statusList;
    @ApiModelProperty("返利状态（0未返利 1已返利 2回收返利 3返利冻结）")
    private Integer reStatus;
    @ApiModelProperty("返利状态列表（0未返利 1已返利 2回收返利 3返利冻结）")
    private List<Integer> reStatusList;
    @ApiModelProperty("订单分类（淘宝、天猫、聚划算、饿了么、淘宝特价版）")
    private Integer orderType;
    @ApiModelProperty("订单来源（0 PC个人微信，1 安卓手机个人微信,2 PC企业微信,3 Ipad协议个人微信,4 CMS, 5 小程序, 6 公众号, 7 单品推荐中间页, 8 个人微信朋友圈")
    private Integer orderSource;
    @ApiModelProperty("联盟账号")
    private String alimmTbId;
    @ApiModelProperty("佣金比例(返利比例大于条件字段)")
    private Double commissionRate;
    @ApiModelProperty("买家返利(买家返利大于条件字段)")
    private Double reUserBal;
    @ApiModelProperty("查询时间类型(createdt-创建时间;paydt-付款时间;accountdt-结算时间;refundCreateTime-维权创建时间;refundFinishTime-维权完成时间")
    private String queryTimeType;
    @ApiModelProperty("查询开始时间")
    private Integer queryStartTime;
    @ApiModelProperty("查询结束时间")
    private Integer queryEndTime;
    @ApiModelProperty("查询月份(默认空表示查询最近三个月)")
    private String queryMonth;
    @ApiModelProperty(value = "查询月份第一天", hidden = true)
    private Integer queryMonthStartTime;
    @ApiModelProperty(value = "查询月份最后一天", hidden = true)
    private Integer queryMonthEndTime;
    @ApiModelProperty(value = "是否是饿了么订单（0否，1是）", hidden = true)
    private Integer elm;
    @ApiModelProperty("免单类型（0非免单，1免单）")
    private Integer free;
    @ApiModelProperty("商品搜索id")
    private String tkItemId;

    public String getOrderNo() {
        return orderNo;
    }

    public void setOrderNo(String orderNo) {
        this.orderNo = orderNo;
    }

    public String getParentOrderNo() {
        return parentOrderNo;
    }

    public void setParentOrderNo(String parentOrderNo) {
        this.parentOrderNo = parentOrderNo;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getItemId() {
        if(StringUtils.isNotBlank(itemId)){
            String[] itemIdArr = itemId.split("-");
            if(itemIdArr != null && itemIdArr.length == 2){
                return itemIdArr[1];
            }
        }
        return itemId;
    }

    public void setItemId(String itemId) {
        this.itemId = itemId;
    }

    public Long getDeviceUniqueId() {
        return deviceUniqueId;
    }

    public void setDeviceUniqueId(Long deviceUniqueId) {
        this.deviceUniqueId = deviceUniqueId;
    }

    public Integer getCid() {
        return cid;
    }

    public void setCid(Integer cid) {
        this.cid = cid;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Integer getReStatus() {
        return reStatus;
    }

    public void setReStatus(Integer reStatus) {
        this.reStatus = reStatus;
    }

    public Integer getOrderType() {
        return orderType;
    }

    public void setOrderType(Integer orderType) {
        this.orderType = orderType;
    }

    public Integer getOrderSource() {
        return orderSource;
    }

    public void setOrderSource(Integer orderSource) {
        this.orderSource = orderSource;
    }

    public String getAlimmTbId() {
        return alimmTbId;
    }

    public void setAlimmTbId(String alimmTbId) {
        this.alimmTbId = alimmTbId;
    }

    public Double getCommissionRate() {
        return commissionRate;
    }

    public void setCommissionRate(Double commissionRate) {
        this.commissionRate = commissionRate;
    }

    public Double getReUserBal() {
        return reUserBal;
    }

    public void setReUserBal(Double reUserBal) {
        this.reUserBal = reUserBal;
    }

    public String getQueryTimeType() {
        return queryTimeType;
    }

    public void setQueryTimeType(String queryTimeType) {
        this.queryTimeType = queryTimeType;
    }

    public Integer getQueryStartTime() {
        return queryStartTime;
    }

    public void setQueryStartTime(Integer queryStartTime) {
        this.queryStartTime = queryStartTime;
    }

    public Integer getQueryEndTime() {
        return queryEndTime;
    }

    public void setQueryEndTime(Integer queryEndTime) {
        this.queryEndTime = queryEndTime;
    }

    public String getQueryMonth() {
        return queryMonth;
    }

    public void setQueryMonth(String queryMonth) {
        this.queryMonth = queryMonth;
    }

    public Integer getQueryMonthStartTime() {
        //如果查询月份不为空，则开始时间为当月得第一天
        if(StringUtils.isNotBlank(queryMonth)){
            queryMonthStartTime =  DateUtil.getStartTimeOrEndTimeByMonth(queryMonth, 0);
        }else {//默认为90天前
//            //获取当前得月份
//            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//            String day = sdf.format(new Date());
//            String currentTime = day + " 00:00:00";
//            String queryStartTime = Tools.getSpecifiedDayBefore(currentTime,"yyyy-MM-dd HH:mm:ss",90);
//            queryMonthStartTime = DateUtil.getStrTime(queryStartTime);
        }
        return queryMonthStartTime;
    }

    public void setQueryMonthStartTime(Integer queryMonthStartTime) {
        this.queryMonthStartTime = queryMonthStartTime;
    }

    public Integer getQueryMonthEndTime() {
        //如果查询月份不为空，则结束时间为当月最后一天
        if(StringUtils.isNotBlank(queryMonth)){
            queryMonthEndTime =  DateUtil.getStartTimeOrEndTimeByMonth(queryMonth, 1);
        }
        return queryMonthEndTime;
    }

    public void setQueryMonthEndTime(Integer queryMonthEndTime) {
        this.queryMonthEndTime = queryMonthEndTime;
    }

    public List<Long> getDeviceUniqueIdList() {
        return deviceUniqueIdList;
    }

    public void setDeviceUniqueIdList(List<Long> deviceUniqueIdList) {
        this.deviceUniqueIdList = deviceUniqueIdList;
    }

    public Integer getElm() {
        return 0; //淘宝订单
    }

    public void setElm(Integer elm) {
        this.elm = elm;
    }

    public Integer getFree() {
        return free;
    }

    public void setFree(Integer free) {
        this.free = free;
    }

    public List<Integer> getStatusList() {
        return statusList;
    }

    public void setStatusList(List<Integer> statusList) {
        this.statusList = statusList;
    }

    public String getTkItemId() {
        return tkItemId;
    }

    public void setTkItemId(String tkItemId) {
        this.tkItemId = tkItemId;
    }

    public List<Integer> getReStatusList() {
        return reStatusList;
    }

    public void setReStatusList(List<Integer> reStatusList) {
        this.reStatusList = reStatusList;
    }
}
